﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Web.Mvc;

namespace IceScream.Models
{
    [MetadataType(typeof(ProductMetadata))]
    public partial class Product
    {
        [Bind(Exclude = "Id")]
        public class ProductMetadata
        {
            
        }

        public string CategoryName
        {
            get {
                DataEntities ctx = new DataEntities();
                return ctx.Categories.Where(s => s.Id == IdCat).Select(s => s.Name).FirstOrDefault() ?? string.Empty;
            }
        }
        
    }
}